package personal.xjl.jerrymouse.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import personal.xjl.jerrymouse.service.AdminServiceImpl;
import personal.xjl.jerrymouse.service.StudentServiceImpl;
import personal.xjl.jerrymouse.service.TeacherServiceImpl;

@Controller
@RequestMapping("/Login")
public class LoginController {
    @Autowired
    StudentServiceImpl studentService;
    @Autowired
    TeacherServiceImpl teacherService;
    @Autowired
    AdminServiceImpl adminService;

    @RequestMapping("login.do")
    public String login(String username,String password,int type){
        switch (type){
            case 1:{
                if (studentService.login(username,password)){
                    return "main";
                }else {
                    return "login";
                }
            }
            case 2:{
                if (teacherService.login(username,password)){
                    return "main";
                }else {
                    return "login";
                }
            }
            case 3:{
                if (adminService.login(username,password)){
                    return "main";
                }else {
                    return "login";
                }
            }
        }
        return "404";
    }
}
